function doRequest(id) {// 验证各项是否合法
	var pars = "id=" + id + "&value=" + $(id).value;
	var myAjax = new Ajax.Request("checklogin.jsp", {
		method : "post",
		parameters : pars,
		onComplete : callBack
	});
}
function callBack(response) {// 回调函数
	var res = response.responseXML.getElementsByTagName("res");
	var id = res[0].firstChild.data;
	var value = res[1].firstChild.data;
	var tips = res[2].firstChild.data;
	var o = $(id + "_tips");
	if (value == 'false') {
		o.innerHTML = "<font color=red>" + tips + "</font>";
	} else
		o.innerHTML = "<img src='" + tips + "' border='0' />";
}

function login() {// 登录
	var pars = "userName=" + $("username").value + "&password="
			+ $("password").value;
	if (pars == "userName=&password=") {
		var o = $("acc");
		o.innerHTML = "用户名和密码不能为空！";
		return false;
	}
	var myAjax = new Ajax.Request("login_submit.jsp", {
		method : "post",
		parameters : pars,
		onComplete : callLogin
	});
	return true;

}
function callLogin(r) {// 回调函数
	var t = r.responseText.trim();
	var o = $("acc");
	if (t == "success") {
		o.innerHTML = "登录成功，三秒后自动跳转到：<a href='index.jsp'>首页</a>";
		setTimeout("window.location='index.jsp'", 3000);
	} else {
		o.innerHTML = t;
	}
}
String.prototype.trim = function() {
	return this.replace(/(^\s*)|(\s*$)/g, '');
}